home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / games1 / 4dtencra.zip / INCPATCH.ASM < prev    next >
Assembly Source File  |  1993-04-13  |  6KB  |  154 lines

  1. ;
  2. ; Patch for 4D Sports Tennis
  3. ;
  4.  
  5. ;
  6. ; Define equates used in the program
  7. ;
  8. cr            EQU            0Dh                 ;carriage return
  9. lf            EQU            0Ah                 ;line feed
  10.  
  11.  
  12.  
  13. code          SEGMENT
  14.               ASSUME         CS:code,DS:code
  15.               ORG            100h
  16.  
  17. strt:
  18. ;
  19. ; Print welcome message
  20. ;
  21.               MOV            DX,OFFSET welcome
  22.               MOV            AH,09h
  23.               INT            21h
  24.  
  25. ;
  26. ; First, we need to open file
  27. ;
  28. open_file:
  29.               MOV            AL,1                ; write only operation
  30.               MOV            DX,OFFSET fname     ; move fname to DX
  31.               MOV            AH,3Dh              ; open file
  32.               INT            21h
  33.               JNC            file_opened         ; jump if no errors
  34.               PUSH           AX                  ; push error code onto stack
  35.               JMP            error               ; jump to error routine
  36.  
  37. file_opened:
  38. ;
  39. ; Now we move the file pointer to the proper location
  40. ;
  41.               MOV            BX,AX               ; move file handle to bx
  42.               MOV            AL,00               ; move pointer from beginning
  43.               MOV            CX,0001h            ; m.s. offset in hex
  44.               MOV            DX,626Fh            ; l.s. offset in hex
  45.               MOV            AH,42h              ; move file pointer
  46.               INT            21h
  47.               JNC            move_ok             ; jump if no errors
  48.               PUSH           AX                  ; push error code onto stack
  49.               JMP            error               ; jump to error routine
  50.  
  51. move_ok:
  52. ;
  53. ;Now we will write the new bytes to the program
  54. ;BX holds file handle
  55. ;
  56.               MOV            CX,1                ; number of bytes to write
  57.               MOV            DX,OFFSET databuff  ; move data to DX
  58.               MOV            AH,40h              ; write to file
  59.               INT            21h
  60.               JNC            write_ok            ; jump if no errors
  61.               PUSH           AX                  ; push error onto stack
  62.               JMP            error               ; jump to error routine
  63.  
  64. write_ok:
  65. ;
  66. ;Now we have to close the file before we leave
  67. ;BX holds file handle
  68. ;
  69.               MOV            AH,3Eh              ; close file
  70.               INT            21h
  71.               JNC            close_ok            ; jump if no errors
  72.               PUSH           AX                  ; push error onto stack
  73.               JMP            error               ; jump to error routine
  74.  
  75. close_ok:
  76.               cmp            byte ptr fname,'V'  ; is the filename 'V'ga
  77.               jz             exit                ; yes, then jump
  78.               mov            byte ptr fname,'V'  ; else make it 'V'ga.exe
  79.               jmp            open_file           ; jump
  80.  
  81. error:
  82. ;
  83. ;Parse the error code returned from the system and display
  84. ;The appropriate error message
  85. ;
  86.               POP            AX                  ; return error code
  87.  
  88.               CMP            AX,1
  89.               JE             code1
  90.               CMP            AX,2
  91.               JE             code2
  92.               CMP            AX,3
  93.               JE             code3
  94.               CMP            AX,4
  95.               JE             code4
  96.               CMP            AX,5
  97.               JE             code5
  98.               CMP            AX,6
  99.               JE             code6
  100.  
  101.  
  102.               MOV            DX,OFFSET nocode    ; no matching error code
  103.               JMP            print_error
  104. code1:        MOV            DX,OFFSET error1    ; invalid function
  105.               JMP            print_error
  106. code2:        MOV            DX,OFFSET error2    ; file not found
  107.               JMP            print_error
  108. code3:        MOV            DX,OFFSET error3    ; path not found
  109.               JMP            print_error
  110. code4:        MOV            DX,OFFSET error4    ; no handle available
  111.               JMP            print_error
  112. code5:        MOV            DX,OFFSET error5    ; access denied
  113.               JMP            print_error
  114. code6:        MOV            DX,OFFSET error6    ; handle invalid
  115.               JMP            print_error
  116.  
  117. ;
  118. ;Display error code to user
  119. ;
  120. print_error:
  121.               MOV            AH,09h              ; display stirng
  122.               INT            21h
  123.  
  124. ;
  125. ;Now we are done so let's close up shop
  126. ;
  127. exit:
  128.               MOV            DX,OFFSET goodbye
  129.               MOV            AH,09h
  130.               INT            21h
  131.  
  132.               MOV            AX,04C00h           ; terminate program
  133.               INT            21h
  134.  
  135. ;
  136. ;Data area
  137. ;
  138. fname         DB             'EGA.EXE',0     ; define file name
  139. welcome       DB             'Generic Patch Maker v1.0',cr,lf
  140.               DB             'Designed by Jake Pickett',cr,lf,lf
  141.               DB             'Please wait while 4D Sports Tennis is '
  142.               DB             'being patched.',cr,lf,'$'
  143. goodbye       DB             'Thank you for choosing INC!',cr,lf,'$'
  144. nocode        DB             '<<Unkown Error Code>>',cr,lf,'$'
  145. error1        DB             '<<Invalid Function>>',cr,lf,'$'
  146. error2        DB             '<<File Not Found>>',cr,lf,'$'
  147. error3        DB             '<<Path Not Found>>',cr,lf,'$'
  148. error4        DB             '<<No Handle Available>>',cr,lf,'$'
  149. error5        DB             '<<Access Denied>>',cr,lf,'$'
  150. error6        DB             '<<Handle Invalid Or Not Open>>',cr,lf,'$'
  151. databuff      DW             0EBh               ; bytes to write out
  152.  
  153. code          ENDS
  154.               END            strt